package com.totcy.constant;

public interface CommonConstant {
    enum ErrorCode {
        CODE0("", 0),
        CODE1001("该邮箱已注册", 1001),
        CODE1002("请求参数不合法",1002),
        CODE1003("用户不存在",1003),
        CODE1004("密码错误",1004),

        CODE5000("服务器内部错误", 5000);

        private String error;
        private int code;

        ErrorCode(String error, int code) {
            this.error = error;
            this.code = code;
        }

        public String getError() {
            return this.error;
        }

        public int getCode() {
            return this.code;
        }

        public static String getError(int code) {
            for (ErrorCode e : ErrorCode.values()) {
                if (e.getCode() == code) {
                    return e.getError();
                }
            }
            return "";
        }
    }

}
